<style>
	.modal-dialog{margin-top: 300px}
	.pull-right li{float: left;margin: 8px 15px 8px 0;list-style-type:none; }
</style>
<div class="row">
	<div class="col-xs-12 col-md-12">
		<div class="widget">
			<div class="widget-header bg-blue">
				<i class="widget-icon fa fa-arrow-down"></i>
				<span class="widget-caption">{$title}</span>
				<div class="widget-buttons">
					<a href="#" data-toggle="maximize">
						<i class="fa fa-expand"></i>
					</a>
					<a href="#" data-toggle="collapse">
						<i class="fa fa-minus"></i>
					</a>
					<a href="#" data-toggle="dispose">
						<i class="fa fa-times"></i>
					</a>
				</div>
			</div>
			<div class="widget-body">
				<div class="table-toolbar">
					{volist name="headButtonWidgets" id="v"}
						<?php $res_sum = 0;foreach ($v['role'] as $item) { $res_sum+=$role[$item];}  ?>
						<?php if($res_sum>0){ ?>
						<a href="{if $v['key']=='back'}{:url($v['url'],array('p'=>$p))}{else}{:url($v['url'],array($classNameId=>$$classNameId,'p'=>$p))}{/if}"
						   class="btn {$v.color} {if $v['check']} checkClick{/if}" data-loader="App-loader"  data-loadername="{$title}"
						   {if $v['data-type']} data-type = "{$v['data-type']}"{/if}
						   {if $v['windowsContent']} data-content = "{$v['windowsContent']}"{/if}
						   {if $v['ajax'] || $v['check']} data-ajax="{:url($v['url'])}"{/if}
						">
							<i class="fa {$v.ico}"></i>{$v.name}
						</a>
						<?php }?>
					{/volist}

					{if condition="$import_url"}
						<a download="导入模版.xlsx" href="/Template.xlsx" class="btn btn-warning" class="btn btn-warning">
	                        <i class="fa fa-download"></i>下载导入模版
	                    </a>
	                    <button class="btn btn-warning" id="uploadform">
	                        <i class="fa fa-plus"></i>导入设备
	                    </button>
	                    <iframe name="formIframe" style="display: none;"></iframe>
	                    <form style="position: absolute;z-index: -1" id="AppForm" action=""
	                          enctype="multipart/form-data" target="formIframe" method="post">
	                        <input type="file" class="btn btn-warning" name="excel"
	                               accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="import" />
	                        <input style="display: inline;z-index: -1;position: absolute" type="submit">
	                        <script type="text/javascript">
	                            $('#import').change(function(){
	                                $('#AppForm').attr('action',"{:url($import_url)}");
	                                $('#AppForm').submit();
	                            })
	                            function callback(res) {
	                                if(res.status) {
	                                    $.App.alert('success',res.msg);
	                                } else {
	                                    $.App.alert('danger',res.msg);
	                                }
	                                $('#refresh-toggler').click();
	                            }
	                            $('#uploadform').click(function(){
	                            	$('#import').click();
	                            })
	                        </script>
	                    </form>
                    {/if}

					<div class="pull-right">
						<form id="App-search"> <!-- action="{:url('Admin/MylUser/userList')}" -->
							<?php $search_cout =0;?>
							{volist name="searchWidgets" id="v"}
							<?php $res_sum = 0;foreach ($v['role'] as $item) {
                                           $res_sum+=$role[$item];
										}  ?>
							<?php if($res_sum>0){ ?>
							<?php $search_cout++;?>
							{if $v.type eq 1}
							<li>
								{if  $search[$v['key']]!=''}
								<span>{$v.name}：</span>
								{/if}

								<label >
									<input name="{$v.key}" type="search" class="form-control input-sm" placeholder="{$v.name}"  value="{$search[$v['key']]}" placeholder="">
								</label></li>
							{/if}
							{if $v.type eq 2}
							<li>
								<span>{$v.name}：</span><label>
								<select name="{$v.key}" class="form-control">
									<option value="0">全部</option>
									{volist name="v.data" id="vo" }
									<option value="{$key}" {if $key eq $search[$v['key']]}selected{/if} >{$vo}</option>
									{/volist}
								</select>
							</label>
							</li>
							{/if}
							{if $v.type eq 3}
							<li>
								<label >
									<div class="col-xs-5" style="padding-left: 0px;padding-right: 0px;width: 300px">
										<div class="input-group margin">
											<span class="input-group-addon">日期搜索</span>
											<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
											<input type="text" class="form-control pull-left" id="play_time" name="{$v.key}" value="{$search[$v['key']]}"/>
										</div>
									</div>
								</label>
							</li>
							{/if}

							<?php }?>
							{/volist}

							{if $search_cout gt 0}
							<li class="">
								<a href="{:url($selfUrl,array($classNameId=>$$classNameId,'p'=>$p))}" class="btn btn-success" data-loader="App-loader" data-loadername="{$title}" data-search="App-search">
									<i class="fa fa-search"></i>搜索
								</a>
							</li>
							{/if}
						</form>
					</div>
				</div>
				{if $navList}
				<div class="form-title">
					{foreach name="navList" item="v"}
						<a href="{:url($selfUrl,array('type_id'=>$key))}"  class="btn  {if $key eq $type_id}btn-info {/if}" data-loader="App-loader" data-loadername="{$v.name}">
						<i></i>{$v.name}
						</a>&nbsp;&nbsp;&nbsp;
					{/foreach}
				</div>
				{/if}
				<table id="App-table" class="table table-bordered table-hover">
					<thead class="bordered-darkorange">

						<tr role="row">
							{if $check}
							<th width="30px">
								<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
									<label style=" padding-left: 4px;"> <input type="checkbox" class="App-checkall colored-blue">
										<span class="text"></span>
									</label>
								</div>
							</th>
							{/if}

							{volist name="list" id="vo"}
							<th>{$vo}</th>
							{/volist}
						</tr>
					</thead>
					<tbody>
						{volist name="data" id="vo" empty="$empty"}
							<tr id="item{$vo.id}">
								{if $check}
								<td>
									<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
										<label style="padding-left: 4px;"> <input name="checkvalue" type="checkbox" class="colored-blue App-check" value="{$vo.id}">
											<span class="text"></span>
										</label>
									</div>
								</td>
								{/if}
								{volist name="list" id="v"}
									{if $v eq '操作'}
										<td class="center ">
											{if $buttonWidgets}
											{volist name="buttonWidgets" id="res"}
												<?php  $res_sum = 0;foreach ($res['role'] as $item) {
                                           $res_sum+=$role[$item];
										}  ?>
												<?php if($res_sum>0){ ?>
												<?php $a=1; if($res['condition']){

										switch($res['condition'][1]){
										case '>':$vo[$res['condition'][0]]>$res['condition'][2]?$a=1:$a=0;break;
												case '>=':$vo[$res['condition'][0]]>=$res['condition'][2]?$a=1:$a=0;break;
												case '=':$vo[$res['condition'][0]]==$res['condition'][2]?$a=1:$a=0;break;
												case '<':$vo[$res['condition'][0]]<$res['condition'][2]?$a=1:$a=0;break;
												case '<=':$vo[$res['condition'][0]]<=$res['condition'][2]?$a=1:$a=0;break;
												} } ?>
												<?php if($a){ ?>
													<?php $cid = $vo['id'];?>
													<a class="btn {$res.color} btn-xs"
													   data-url = "{:url($res['url'],array('id'=>$vo['id'],$classNameId=>$cid))}"
													<?php if($res['data-type']){ ?> data-type = "{$res['data-type']}"  <?php }?>
													<?php if($res['windowsContent']){ ?> data-content = "{$res['windowsContent']}"  <?php }?>
													{if $res['ajax'] eq 1}
														data-ajax="{:url($res['url'],array('id'=>$vo['id'],$classNameId=>$cid))}"
													{elseif $res['ajax'] eq 2}
														href="javascript:void(0)"
													{else}
														href="{:url($res['url'],array('id'=>$vo['id'],$classNameId=>$cid))}"
														data-loader="App-loader"
													{/if}
													data-id = "{$vo['id']}"
													{if condition="$res['addData']"}
														{volist name="res['addData']" id="value"}
															data-{$value}="{$vo[$value]}"
														{/volist}
													{/if}
													{if condition="$res['bindEvents']"}

														{volist name="res['bindEvents']" id="event"}
															{$key}="{$event}(this)" 
														{/volist}
													{/if}
													>
													<i class="fa {$res.ico}"></i> {$res.name}
													</a>&nbsp;&nbsp;
												<?php }?>
												<?php }?>
											{/volist}
											{/if}
										</td>

										{else}
											<td class=" ">
												{if strstr($key,'time')&&strlen($vo[$key])==10}
													{$vo[$key]|date='Y-m-d H:i:s',###}
												{elseif strstr($key,'img')}
													<!--判断是否数组-->
													{if is_array($vo[$key])}
													{volist name="vo[$key]" id="imgs"}
													<img onclick="preViem(this)" width="50px" height="50px" src="{$imgs}" style="margin-right:10px;" />
													{/volist}
													{else}
													<img onclick="preViem(this)" width="50px" height="50px" src="{$vo[$key]}" style="margin-right:10px;" />
													{/if}
												{else}
												{$vo[$key]}
												{/if}

											</td>
									{/if}
								{/volist}

							</tr>
						{/volist}
												
					</tbody>
				</table>
				{if isset($statistics)}
				<div class="row DTTTFooter">
					<p style="padding-left: 15px">
						{volist name="statistics" id="v"}
						<b style="margin-right: 15px;font-weight: 200">
							{$v}
						</b>
						{/volist}
					</p>
				</div>
				{/if}
				<div class="row DTTTFooter">
					{$page}
				</div>
			</div>
		</div>
	</div>
</div>

<script src="{$Think.config.dlcjs}datetime/moment.js"></script>
<script src="{$Think.config.dlcjs}datetime/daterangepicker.js"></script>
<script src="{$Think.config.dlcjs}public.js"></script>
<!--面包屑导航封装-->
<div id="tmpbread" style="display: none;">{$breadhtml}</div>
<script type="text/javascript">
	setBread($('#tmpbread').html());
	//全选
    $('#App-loader-title').text("{$title}")
	var checkall=$('#App-table .App-checkall');
	var checks=$('#App-table .App-check');
	var trs=$('#App-table tbody tr');
	$(checkall).on('click',function(){
		if($(this).is(":checked")){			
			$(checks).prop("checked","checked");
		}else{
			$(checks).removeAttr("checked");
		}		
	});
	$(trs).on('click',function(){
		var c=$(this).find("input[type=checkbox]");
		if($(c).is(":checked")){
			$(c).removeAttr("checked");
		}else{
			$(c).prop("checked","checked");
		}		
	});

	//勾选 点击事件
    $(".checkClick").click( function () {
        var checks=$(".App-check:checked");
        var chk='';
        $(checks).each(function(){
            chk+=$(this).val()+',';
        });
        if(chk){
            url = $(this).attr('href');
            if (url.split('.html').length>1){
				arr = url.split('.html');
				url = arr[0]+'/ids/'+chk+'.html';
			}else {
                url = url+'/ids/'.chk;
			}
            $(this).attr("data-ajax",url);
            console.log(this)
        }else {
            url = $(this).attr('href');
            $(this).attr("data-ajax",url);
            // $.App.alert('danger','请勾选');
            // return false;
        }
    });


    $('#play_time').daterangepicker({
        showDropdowns: true,
        ranges: {
            '今天': [moment(), moment()],
            '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
            '最近7天': [moment().subtract('days', 6), moment()],
            '最近30天': [moment().subtract('days', 29), moment()],
            '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
        },
        locale: {
            customRangeLabel: '自定义',
        },
    });
//图片放大
    function preViem(obj) {
        var img = $(obj).attr('src');
        bootbox.dialog({
            message: "<div><img style='width:570px;' src='"+img+"'></div>",
            title: "图片预览",
            className: "modal-darkorange",
            buttons: {
                success: {
                    label: "确定",
                    className: "btn-blue",
                    callback: function() {}
                }
            }
        });
    }

    //弹出新窗口
    function openNewWindows(obj){
		$id = $(obj).data('id');
		$title = $(obj).text();
        $.ajax({
            type: "post",
            url: $(obj).data('url'),
            data:{'id':$id},
            dataType: "html",
            height: 200,
            //beforeSend:$.App.loading(),
            success: function(mb) {
                bootbox.dialog({
                    message: mb,
                    title: $title,
                    buttons: {
                    }
                });
            },
            error: function(xhr) {
                $.App.alert('danger', '通讯失败！请重试！');
            }
        });
        return false;
    }
</script>
<!--/全选特效封装-->  